using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Admin_DanhSachSeminar : System.Web.UI.Page
{
    private int NUM_ROWS_PER_PAGE = 4;
    private int TRANG_HH = 1;
    private int TONG_DONG = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LayDuLieu();
            
        }
        SeminarBUS sBus = new SeminarBUS();
        DataTable dt = sBus.getBangSeminarChiTiet();
        TONG_DONG = dt.Rows.Count;
        int kt = TONG_DONG % NUM_ROWS_PER_PAGE ;
        int soDong = TONG_DONG / NUM_ROWS_PER_PAGE;
        if (kt != 0)
            soDong += 1;
        int TONG_TRANG = (int)(soDong);
        numberPaging.Text = TONG_TRANG.ToString();
        
    }
    
    private void LayDuLieu()
    {
        SeminarBUS sBus = new SeminarBUS();
        DataTable dt = sBus.getBangSeminarChiTiet((TRANG_HH - 1)* NUM_ROWS_PER_PAGE , NUM_ROWS_PER_PAGE);
        GridView1.DataSource = dt;
        GridView1.DataBind();
        pagingLabel.Text = TRANG_HH.ToString();
    }
    protected void LinkButton2_Click(object sender, EventArgs e)
    {
        TRANG_HH = int.Parse(pagingLabel.Text) + 1;
        LayDuLieu();
        if ( TRANG_HH * NUM_ROWS_PER_PAGE >= TONG_DONG)
        {
            LinkButton2.Visible = false;
        }
        if (TRANG_HH != 1)
            LinkButton1.Visible = true;
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        TRANG_HH = int.Parse(pagingLabel.Text) - 1;
        LayDuLieu();
        if ( TRANG_HH == 1)
        {
            LinkButton1.Visible = false;
        }
        if (TRANG_HH * NUM_ROWS_PER_PAGE < TONG_DONG)
            LinkButton2.Visible = true;
    }
    
    protected void xemChiTietSeminar(object sender, EventArgs e)
    {
        LinkButton lb = (LinkButton)sender;
        if (lb.CommandName == "xemChiTiet") 
        {
            Response.Redirect("~/Admin/XemChiTietSeminar.aspx?idSeminar=" + lb.CommandArgument);
        }
    }
    protected void capNhatSeminar(object sender, EventArgs e)
    {
        ImageButton ib = (ImageButton)sender;
        if (ib.CommandName == "CapNhat")
        {
            Response.Redirect("~/Admin/CapNhatThongTinSeminar.aspx?idSeminar=" + ib.CommandArgument);
        }
    }
}
